import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:mobile_vpn/pages/home_page/home_page.dart';
import 'package:mobile_vpn/pages/member_page/member_page.dart';

import '../../common/cpn/keep_alive_wrapper.dart';
import '../discovery_page/discovery_page.dart';
import '../my_page/my_page.dart';

class IndexLogic extends GetxController with WidgetsBindingObserver {
  RxInt index = 0.obs;
  PageController pageController = PageController(initialPage: 0);

  final List<Widget> navPages = [
    KeepAliveWrapper(child: HomePage()),
    KeepAliveWrapper(child: MemberPage()),
    KeepAliveWrapper(child: DiscoveryPage()),
    KeepAliveWrapper(child: MyPage()),

   //   //KeepAliveWrapper(child: DiscoveryPage()),
   // // const KeepAliveWrapper(child: PublishPage()),
   //  KeepAliveWrapper(child: MessagePage()),
   //  KeepAliveWrapper(child: ServicePage()),
   //  KeepAliveWrapper(child: ServicePage()),
   //  const KeepAliveWrapper(child: MyPage()),
  ];

  void navigate(int index) {
    this.index.value = index;
    pageController.jumpToPage(index);
    // updateStatusBarColor(Colors.transparent, index != 1);
    // eventBus.fire(IndexNavigationIndexChangedEvent(index));
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    super.didChangeAppLifecycleState(state);
    print("调用");
    //eventBus.fire(AppLifecycleStateEvent(state));
  }
}
